package com.example.cato_mongodb.entity;

import com.sun.istack.internal.NotNull;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.rest.core.annotation.RestResource;

import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

@Data
@RestResource(rel = "tacos",path = "tacos")
@Document
public class Taco {

    @Id  // 可以用到任意serializable类型上，，保存时让Mongodb自动赋值
    private String id;

    @NotNull
    @Size(min = 5,message = "Name must be ad least 5 characters long")
    private String name;

    private Date createAt = new Date();

    @Size(min = 1,message = "You must choose at least 1 ingredient")
    private List<Ingredient> ingredients;




}
